<?php
namespace Auth\Form;

use Zend\Form\Form;
use Zend\Stdlib\Hydrator\ClassMethods;

class RegistrationForm extends Form
{
	public function __construct($name = null)
	{
		parent::__construct('registration');
		$this->setAttribute('method', 'post')
             ->setInputFilter(new \Auth\Form\RegistrationFilter(NULL))
             ->setHydrator(new ClassMethods())
             ->setAttribute('class', 'form-signup');
		
		$this->add(array(
			'name' => 'usr_name' ,
			'attributes' => array(
				'type' => 'text' ,
                'class' => 'form-control col-xs-12 username',
                'placeholder' => 'User',
			),
            'options' => array(
                'label' => 'username' ,
                'label_attributes' => array(
                    'class' => 'col-xs-12 control-label no-padding-right'
                ),               
            ),
		));
		
        $this->add(array(
            'name' => 'usr_email',
            'attributes' => array(
                'type'  => 'email',
                'class' => 'form-control col-xs-12 email',
                'placeholder' => 'Email',
            ),
            'options' => array(
                'label' => 'E-mail',
                'label_attributes' => array(
                    'class' => 'col-xs-12 control-label no-padding-right'
                ),   
            ),
        ));	
		
        $this->add(array(
            'name' => 'usr_password',
            'attributes' => array(
                'type'  => 'password',
                'class' => 'form-control col-xs-12 password',
                'placeholder' => 'Password',
            ),
            'options' => array(
                'label' => 'Password',
                'label_attributes' => array(
                    'class' => 'col-xs-12 control-label no-padding-right'
                ),   
            ),
        ));
		
        $this->add(array(
            'name' => 'usr_password_confirm',
            'attributes' => array(
                'type'  => 'password',
                'class' => 'form-control col-xs-12 config-password',
                'placeholder' => 'Password',
            ),
            'options' => array(
                'label' => 'Confirm Password',
                 'label_attributes' => array(
                    'class' => 'col-xs-12 control-label no-padding-right'
                ),  
            ),
        ));	
        
        $dirdata = './data';//http://localhost/ZendSkeletonApplication/data';

        $captchaImage = new \Zend\Captcha\Image(array(
            'font' => $dirdata . '/fonts/arial.ttf',
            'width' => 250,
            'height' => 100,
        ));
        
        $captchaImage->setImgDir($dirdata.'/captcha');
        $captchaImage->setImgUrl('/ZendSkeletonApplication/data/captcha');
        //die(print_r($captchaImage));
        
		$this->add(array(
			'type' => 'Zend\Form\Element\Captcha',
			'name' => 'captcha',
            'attributes' => array(
                'class' => 'form-control col-xs-12 password',
                'placeholder' => 'captcha',
            ),
			'options' => array(
				'label' => 'Please verify you are human',
				'captcha' => $captchaImage , //new \Zend\Captcha\Figlet(),
			),
		));
		
        $this->add(array(
            'name' => 'submit',
            'attributes' => array(
                'type'  => 'submit',
                'value' => 'Go',
                'class' => 'btn btn-primary' ,
                'id' => 'submitbutton',
            ),
        )); 
	}   
}